package platform;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProcessOutputFetcher {
	
	public String getProcessOutput(Process p) throws IOException {
		if(p==null) {
			return "";
		}
		StringBuffer sb = new StringBuffer();
		BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
		InputStreamReader isr = new InputStreamReader(bis);
		BufferedReader br = new BufferedReader(isr);
		String line = null;
		while (null != (line = br.readLine())) {
			sb.append(line).append('\n');
		}
		return sb.toString();
	}
}
